<?php
// +----------------------------------------------------------------------
// | sfadmin - Suifeng Administration
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2020 http://suifeng.tech All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: suifeng <1787585212@qq.com>
// +----------------------------------------------------------------------

namespace suifeng\builder\table\column;

use suifeng\builder\table\Column;

class Selected extends Column
{
    /**
     * 获取标题内容。
     *
     * @param string $config
     */
    public function __construct($config = array())
    {
        parent::__construct($config);

        if (empty($this->head_attributes['class'])) {
            $this->head_attributes['class'] = 'list-ids';
        }

        if (empty($this->head_attributes['width'])) {
            $this->head_attributes['width'] = '30';
        }
    }

    /**
     * 输出标题。
     *
     * @return string
     */
    protected function _fetch_head_content()
    {
        return <<<EOF
        <input type="checkbox" class="check-all" >
EOF;
    }

//     protected function _fetch_head_content()
//     {
//         return <<<EOF
// <div class="checkbox-inline lyui-control lyui-checkbox m-l-xs">
//     <label class="checkbox-label">
//         <input type="checkbox" class="check-all" >
//         <span class="lyui-control-indicator"></span>
//     </label>
// </div>
// EOF;
//     }


    /**
     * 获取单元格内容。
     *
     * @param unknown $row
     * @return unknown|string
     */
    protected function _fetch_cell_content($row)
    {
        $value = $this->_get_key_value($row);
        return <<<EOF
        <input class="ids" type="checkbox" value="${value}" name="ids[]">
EOF;
    }

//     <div class="checkbox-inline lyui-control lyui-checkbox m-l-xs">
//     <label class="checkbox-label">
//     <input class="ids" type="checkbox" value="${value}" name="ids[]">
//     <span class="lyui-control-indicator"></span>
//     </label>
//     </div>
//     EOF;
}
